package me.zhengjie.modules.management.job;

import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.management.domain.RoomUserView;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.UserRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: chenxin.jiang
 * @Date: 2020/12/21
 * @Description:
 */
@Service
@RequiredArgsConstructor
public class UserJobService {

    private final UserRepository userRepository;

    /*public void Sys(){
        //查询中间库视图里所有的用户数据，后期改为时间内修改数据。
        List<RoomUserView> all = userJobRepository.findAll();

        //遍历从中间库视图里查出来的数据
        if (ObjectUtil.isNotEmpty(all)){
            for (RoomUserView hrUserAllInfo : all) {
            //根据userId从sys_user里查询用户数据
                User user = userRepository.findUserById(hrUserAllInfo.getUserId());
                if (ObjectUtil.isEmpty(user)){
                    user=new User();
                    //将sys_user里需要同步的字段进行赋值
                    user.setId(hrUserAllInfo.getUserId());
                    user.setUsername(hrUserAllInfo.getName());
                    user.setPhone(hrUserAllInfo.getMobilePhone());
                    user.setEmail(hrUserAllInfo.getEmail());
                    //将更新的user放进sys_user...

                }

            }
        }
    }*/
}
